* Labor market flexibility and the growth-exchange rate relationship
* Asali, Muhammad; Kuokštis, Vytautas; Spurga, Simonas Algirdas
* Version: 25-07-2025

*********************************************************
* Table 1: Summary Statistics and Graphs. Figures 1 and 2
*********************************************************
use AKS_LMF_FXR, clear
set cformat %9.3f
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4
gen LMF=cbr3

* Figure 1:
heatplot cbr3 Country Year, by(FXR)

* Figure 3:
twoway scatter Year CountryID if cbr3~=., legend(label(1 CBR)) msymbol(square) mlwidth(none) msize(vsmall) || scatter Year CountryID if labor~=., legend(label(2 Fraser)) mfcolor(%0) msymbol(square) msize(vsmall) mlwidth(vthin) xlabel(1(1)213, valuelabel angle(vertical) labsize(half_tiny)) xtitle("")

* Table 1: Summary statistics for the actual working sample
qui xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year, fe robust
gen Sample=e(sample)
keep if Sample==1

pwcorr cbr1 cbr2 cbr3, sig

gen PopMillions=Populationtotal/1000000
gen GDP_PC_Thousands=GDPpercapitaconstant2015US/1000

bys FXR: sum growth cbr3 GDP_PC_Thousands PopMillions PGR if Year==1971
bys FXR: sum growth cbr3 GDP_PC_Thousands PopMillions PGR if Year==2000
bys FXR: sum growth cbr3 GDP_PC_Thousands PopMillions PGR if Year==2019
bys FXR: sum growth cbr3 GDP_PC_Thousands PopMillions PGR

***************************************************
* Table 2 & 3: Main results, different CBR measures
***************************************************
use AKS_LMF_FXR, clear
set cformat %9.3f
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4

* Column 5: CBR3
gen LMF=cbr3 // PCA on 5 categories of CBR
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year, fe robust
gen C3=e(sample)
margins, dydx(L.FXR) at(L.LMF=(0(1)10))
* Figure 2
marginsplot, level(95)

* Columns 1-2: without flexibility
xtreg growth L.FXR lnPOP PGR L.ln_gdp_pc Year, fe robust
xtreg growth L.FXR lnPOP PGR L.ln_gdp_pc Year if C3==1, fe robust

* Columns 3-4: CBR1 and CBR2
capture drop LMF
gen LMF=cbr1  // PCA 40 elements
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year, fe robust
margins, dydx(L.FXR) at(L.LMF=(0(1)10))

capture drop LMF
gen LMF=cbr2 // Mean of all (nonmissing) 40 elements
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year if C3==1, fe robust
margins, dydx(L.FXR) at(L.LMF=(0(1)10))

**********************************************
* Table 4 & 5: Dynamic Model and total effects
**********************************************
use AKS_LMF_FXR, clear
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4
gen LMF=cbr3
gen LMF_FXR=LMF*FXR

xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR L.growth lnPOP PGR L.ln_gdp_pc Year, fe robust
gen _FEsample=e(sample)
margins, dydx(L.FXR) at(L.LMF=(0(1)10)) force
nlcom (_b[L.FXR]+_b[c.L.LMF#c.L.FXR]*0)/(1-_b[L.growth])
nlcom (_b[L.FXR]+_b[c.L.LMF#c.L.FXR]*5)/(1-_b[L.growth])
nlcom (_b[L.FXR]+_b[c.L.LMF#c.L.FXR]*10)/(1-_b[L.growth])

xtreg growth L.FXR L.growth lnPOP PGR L.ln_gdp_pc Year if _FEsample==1, fe robust
nlcom _b[L.FXR]/(1-_b[L.growth])
xtabond growth L.FXR L.LMF L.LMF_FXR lnPOP PGR L.ln_gdp_pc Year, vce(robust)
nlcom (_b[L.FXR]+ 0*_b[L.LMF_FXR])/(1-_b[L.growth])
 // at LMF=5
nlcom (_b[L.FXR]+ 5*_b[L.LMF_FXR]) //SR
nlcom (_b[L.FXR]+ 5*_b[L.LMF_FXR])/(1-_b[L.growth])
 // at LMF=10
nlcom (_b[L.FXR]+10*_b[L.LMF_FXR]) //SR
nlcom (_b[L.FXR]+10*_b[L.LMF_FXR])/(1-_b[L.growth])

di "R2 after xtabond = " e(chi2)/(e(N)-e(N_g)-e(df_m)-1+e(chi2))

*********************************
* Table 6: Developing & Developed
*********************************
use AKS_LMF_FXR, clear
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4
gen LMF=cbr3
gen LMF_FXR=LMF*FXR

xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year if developed==0, fe robust
margins, dydx(L.FXR) at(L.LMF=(0 5 10))

xtabond growth L.FXR L.LMF L.LMF_FXR     lnPOP PGR L.ln_gdp_pc Year if developed==0, vce(robust)
di "R2 after xtabond = " e(chi2)/(e(N)-e(N_g)-e(df_m)-1+e(chi2))
nlcom (_b[L.FXR]+ 0*_b[L.LMF_FXR])/(1-_b[L.growth])
nlcom (_b[L.FXR]+10*_b[L.LMF_FXR])/(1-_b[L.growth])

xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year if developed==1, fe robust
xtabond growth L.FXR L.LMF L.LMF_FXR              lnPOP PGR L.ln_gdp_pc Year if developed==1, vce(robust)
di "R2 after xtabond = " e(chi2)/(e(N)-e(N_g)-e(df_m)-1+e(chi2))

***********************************
* Table 7: Continuous Exchange Rate
***********************************
use AKS_LMF_FXR, clear
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4
capture drop LMF
gen LMF=cbr3
ren Fine_new Fixity // 1 free to 13 fixed
gen LMF_FXR=LMF*Fixity

xtreg growth L.Fixity L.LMF c.L.LMF#c.L.Fixity  lnPOP PGR L.ln_gdp_pc Year, fe robust
gen _Sample=e(sample)
margins, dydx(L.Fixity) at(L.LMF=(0(1)10))

xtreg growth L.Fixity lnPOP PGR L.ln_gdp_pc Year if _Sample==1, fe robust

xtreg growth L.Fixity L.LMF c.L.LMF#c.L.Fixity lnPOP PGR L.ln_gdp_pc Year L.growth, fe robust

xtabond growth L.Fixity L.LMF L.LMF_FXR lnPOP PGR L.ln_gdp_pc Year, vce(robust)
di "R2 after xtabond = " e(chi2)/(e(N)-e(N_g)-e(df_m)-1+e(chi2))

nlcom (_b[L.Fixity]+ 0*_b[L.LMF_FXR])/(1-_b[L.growth])
nlcom (_b[L.Fixity]+ 5*_b[L.LMF_FXR])/(1-_b[L.growth])
nlcom (_b[L.Fixity]+10*_b[L.LMF_FXR])/(1-_b[L.growth])

*************************
* Table 8: Fraser vs. CBR
*************************
use AKS_LMF_FXR, clear
gen FXR=(Coarse==1 | Coarse==2)
drop if Coarse>4
gen Lcbr3=L.cbr3
gen Llabor=L.labor

// Fraser Results for nonmissing observations of CBR & Fraser
capture drop LMF
gen LMF=labor
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR  lnPOP PGR L.ln_gdp_pc Year if Llabor~=. & Lcbr3~=. , fe robust
margins, dydx(L.FXR) at(L.LMF=(0(5)10))

// CBR results for nonmissing observations of CBR & Fraser
capture drop LMF
gen LMF=cbr3
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR  lnPOP PGR L.ln_gdp_pc Year if Llabor~=. & Lcbr3~=. , fe robust
margins, dydx(L.FXR) at(L.LMF=(0(5)10))

// CBR Results for all available data
xtreg growth L.FXR L.LMF c.L.LMF#c.L.FXR  lnPOP PGR L.ln_gdp_pc Year                        , fe robust
margins, dydx(L.FXR) at(L.LMF=(0(1)10))

// Imputed Fraser for the full sample
capture drop ImputedFraser
reg labor IA IB IC ID IE
predict ImputedFraser
replace ImputedFraser=labor if labor~=.
replace ImputedFraser=. if cbr3==.
capture drop LMF
gen LMF=ImputedFraser
xtreg growth L.FXR L.LMF  c.L.LMF#c.L.FXR lnPOP PGR L.ln_gdp_pc Year , fe robust
lincom _b[L.FXR]+10*_b[c.L.LMF#c.L.FXR]
margins, dydx(L.FXR) at(L.LMF=(0(5)10))

* Correlations and summary CBR3/Fraser:
pwcorr cbr3 labor Imputed, sig